package study.cell_game.scenes;

import org.andengine.engine.Engine;
import org.andengine.engine.camera.Camera;
import org.andengine.entity.modifier.MoveXModifier;
import org.andengine.entity.modifier.MoveYModifier;
import org.andengine.entity.scene.background.SpriteBackground;
import org.andengine.entity.scene.menu.MenuScene;
import org.andengine.entity.scene.menu.item.IMenuItem;
import org.andengine.entity.scene.menu.item.SpriteMenuItem;
import org.andengine.entity.scene.menu.item.decorator.ScaleMenuItemDecorator;
import org.andengine.entity.sprite.Sprite;
import org.andengine.util.modifier.ease.EaseLinear;

import study.cell_game.activity.GameActivity;
import study.cell_game.objects.Textures;
import study.cell_game.objects.textures.MainMenuTextures;

public class MainMenuScene extends MenuScene {
	private MainMenuTextures textures;
	
	public static final int OPTIONS_BUTTON = 0;
	public static final int PLAY_BUTTON = 1;
	public static final int QUIT_BUTTON = 2;
	public static final int LOAD_BUTTON = 3;
	
	
	public MainMenuScene(Camera mCamera, Engine mEngine, IOnMenuItemClickListener listener, MainMenuTextures menuTextures){
		super(mCamera, listener);
		textures = menuTextures;
		//this.gameScene = new GameScene();
		
	    final IMenuItem optionsMenuItem = new ScaleMenuItemDecorator(new SpriteMenuItem(OPTIONS_BUTTON, textures.getSettingsButtonTextureRegion(), mEngine.getVertexBufferObjectManager()),1.5f, 1);
	    final IMenuItem playMenuItem = new ScaleMenuItemDecorator(new SpriteMenuItem(PLAY_BUTTON, textures.getNewGameButtonTextureRegion(), mEngine.getVertexBufferObjectManager()), 1.5f, 1);
	    final IMenuItem quitMenuItem = new ScaleMenuItemDecorator(new SpriteMenuItem(QUIT_BUTTON, textures.getQuitGameButtonTextureRegion(), mEngine.getVertexBufferObjectManager()), 1.5f, 1);
	    final IMenuItem loadMenuItem = new ScaleMenuItemDecorator(new SpriteMenuItem(LOAD_BUTTON, textures.getLoadGameButtonTextureRegion(), mEngine.getVertexBufferObjectManager()), 1.5f, 1);
	    
	    
	    
	    setBackgroundEnabled(true);
	    setBackground(new SpriteBackground(new Sprite(0, 0, GameActivity.mTextures.getGradient(), GameActivity.main.getVertexBufferObjectManager())));
		attachChild(new Sprite(0,0,GameActivity.mTextures.getBackground(), GameActivity.main.getVertexBufferObjectManager()));
		attachChild(new Sprite(160,-65,textures.getBackgroundElementTextureRegion(), GameActivity.main.getVertexBufferObjectManager()));
		
		
		optionsMenuItem.registerEntityModifier(new MoveYModifier(1.0f, 197, 197, EaseLinear.getInstance()));
		loadMenuItem.registerEntityModifier(new MoveYModifier(1.0f, 293, 293, EaseLinear.getInstance()));
		quitMenuItem.registerEntityModifier(new MoveYModifier(1.0f, 389, 389, EaseLinear.getInstance()));
		
		addMenuItem(playMenuItem);
	    addMenuItem(optionsMenuItem);
	    addMenuItem(loadMenuItem);
	    addMenuItem(quitMenuItem);
	    
	    buildAnimations();
	}
	
}
